package com.c2.pandora;

import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;

public class Pandora extends JFrame {

	private JPanel contentPane;
	private JTextField textField;
	private JTextField textField_1;
	private JPasswordField passwordField;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					UIManager.setLookAndFeel("com.peterswing.white.PeterSwingWhiteLookAndFeel");
				} catch (Exception e) {
					e.printStackTrace();
				}

				try {
					com.apple.eawt.Application macApp = com.apple.eawt.Application.getApplication();
					macApp.setDockIconImage(new ImageIcon(getClass().getClassLoader().getResource("com/c2/pandora/image/c2_logo.png")).getImage());
					macApp.addApplicationListener(new MacAboutBoxHandler());
				} catch (Exception e) {
				}

				Pandora frame = new Pandora();
				frame.setLocationRelativeTo(null);
				frame.setVisible(true);
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public Pandora() {
		setResizable(false);
		setTitle("Login");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 317, 282);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);

		JLabel lblIp = new JLabel("IP");

		JLabel lblNewLabel = new JLabel("");
		lblNewLabel.setIcon(new ImageIcon(Pandora.class.getResource("/com/c2/pandora/image/c2-pandora.png")));

		textField = new JTextField();
		textField.setColumns(10);

		JLabel lblUsername = new JLabel("Username");

		JLabel lblPassword = new JLabel("Password");

		textField_1 = new JTextField();
		textField_1.setColumns(10);

		passwordField = new JPasswordField();

		JButton btnLogin = new JButton("Login");
		btnLogin.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Pandora.this.setVisible(false);
				new MainFrame().setVisible(true);
			}
		});
		GroupLayout gl_contentPane = new GroupLayout(contentPane);
		gl_contentPane.setHorizontalGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING).addGroup(
				gl_contentPane
						.createSequentialGroup()
						.addGroup(
								gl_contentPane
										.createParallelGroup(Alignment.LEADING)
										.addGroup(gl_contentPane.createSequentialGroup().addGap(40).addComponent(lblNewLabel))
										.addGroup(
												gl_contentPane
														.createSequentialGroup()
														.addGap(51)
														.addGroup(
																gl_contentPane
																		.createParallelGroup(Alignment.LEADING)
																		.addGroup(
																				gl_contentPane.createSequentialGroup().addComponent(lblIp).addGap(70)
																						.addComponent(textField, GroupLayout.PREFERRED_SIZE, 155, GroupLayout.PREFERRED_SIZE))
																		.addGroup(
																				gl_contentPane.createSequentialGroup().addComponent(lblUsername).addGap(22)
																						.addComponent(textField_1, GroupLayout.PREFERRED_SIZE, 155, GroupLayout.PREFERRED_SIZE))
																		.addGroup(
																				gl_contentPane
																						.createSequentialGroup()
																						.addComponent(lblPassword, GroupLayout.PREFERRED_SIZE, 62, GroupLayout.PREFERRED_SIZE)
																						.addGap(18)
																						.addGroup(
																								gl_contentPane.createParallelGroup(Alignment.LEADING).addComponent(btnLogin)
																										.addComponent(passwordField)))))).addContainerGap(21, Short.MAX_VALUE)));
		gl_contentPane.setVerticalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING).addGroup(
				gl_contentPane
						.createSequentialGroup()
						.addGap(31)
						.addComponent(lblNewLabel)
						.addGap(38)
						.addGroup(
								gl_contentPane.createParallelGroup(Alignment.BASELINE)
										.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent(lblIp))
						.addGap(12)
						.addGroup(
								gl_contentPane.createParallelGroup(Alignment.BASELINE).addComponent(lblUsername)
										.addComponent(textField_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
						.addPreferredGap(ComponentPlacement.UNRELATED)
						.addGroup(
								gl_contentPane.createParallelGroup(Alignment.BASELINE)
										.addComponent(passwordField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent(lblPassword))
						.addGap(18).addComponent(btnLogin).addContainerGap(25, Short.MAX_VALUE)));
		contentPane.setLayout(gl_contentPane);
	}
}
